package com.sks.bean.pojo;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.sks.bean.privilege.Employee;

/**
 * AuditHistory entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "audit_history")
public class AuditHistory implements java.io.Serializable {
	
	public static String OBJ_TYPE_HOUSE = "house";
	
	public static String OBJ_TYPE_BUILDING = "building";
	
	public static String OBJ_TYPE_NEWS = "news";

	// Fields

	private Integer ahId;
	private Employee employee;
	private String objType;
	private Integer objId;
	private Date ts;
	private String fromStatus;
	private String toStatus;
	
	private Building building;
	private House house;
	private News news;

	// Constructors

	/** default constructor */
	public AuditHistory() {
	}

	/** full constructor */
	public AuditHistory(Employee employee, String objType, Integer objId,
			Date ts, String fromStatus, String toStatus) {
		this.employee = employee;
		this.objType = objType;
		this.objId = objId;
		this.ts = ts;
		this.fromStatus = fromStatus;
		this.toStatus = toStatus;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ahId", unique = true, nullable = false)
	public Integer getAhId() {
		return this.ahId;
	}

	public void setAhId(Integer ahId) {
		this.ahId = ahId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "username", nullable = false)
	public Employee getEmployee() {
		return this.employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	@Column(name = "objType", nullable = false, length = 12)
	public String getObjType() {
		return this.objType;
	}

	public void setObjType(String objType) {
		this.objType = objType;
	}

	@Column(name = "objId", nullable = false)
	public Integer getObjId() {
		return this.objId;
	}

	public void setObjId(Integer objId) {
		this.objId = objId;
	}

	@Column(name = "ts", nullable = false, length = 19)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getTs() {
		return this.ts;
	}

	public void setTs(Date ts) {
		this.ts = ts;
	}

	@Column(name = "fromStatus", nullable = false, length = 12)
	public String getFromStatus() {
		return this.fromStatus;
	}

	public void setFromStatus(String fromStatus) {
		this.fromStatus = fromStatus;
	}

	@Column(name = "toStatus", nullable = false, length = 12)
	public String getToStatus() {
		return this.toStatus;
	}

	public void setToStatus(String toStatus) {
		this.toStatus = toStatus;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "objId", unique = false, nullable = true, insertable = false, updatable = false)
	public Building getBuilding() {
		return building;
	}

	public void setBuilding(Building building) {
		this.building = building;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "objId", unique = false, nullable = true, insertable = false, updatable = false)
	public House getHouse() {
		return house;
	}

	public void setHouse(House house) {
		this.house = house;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "objId", unique = false, nullable = true, insertable = false, updatable = false)
	public News getNews() {
		return news;
	}

	public void setNews(News news) {
		this.news = news;
	}

}